<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			var arr = [];
			arr[0] = 0;
			arr[1] = 1;
			// console.log(arr);
			// console.log(arr[2]); //undefined

			var arr2 = new Array(5, 1);
			// console.log(arr2.length); //5
		</script>
		<script type="text/javascript">
			var arr3 = [6, 10, 12, 2, 19, 5];
			//最大(小)值
			/* 
			  arr3[0] > arr3[1] 
			  arr3[0] > arr3[2]
			  arr3[2] > arr3[3]
			  arr3[2] > arr3[4]
		    */
			/* var max = arr3[0];
			for (var i = 1; i < arr3.length; i++) {
				if (arr3[i] > max) {
					max = arr3[i];
				}
			}
			console.log(max); */

			//排序（小到大）选择排序
			var t;
			for (var i = 0; i < arr3.length; i++) { //控制比较的轮数
				for (var j = i + 1; j < arr3.length; j++) { //每一轮中比较的次数
					if (arr3[i] > arr3[j]) {
						t = arr3[i];
						arr3[i] = arr3[j];
						arr3[j] = t;
					}
				}
			}
			console.log(arr3);
		</script>
	</head>
	<body>
	</body>
</html>
